/*
 * Copyright 2002-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.core;

import org.springframework.lang.Nullable;

/**
 * AttributeAccessor:定义用于附加和访问元数据的通用的接口，来自任意对象
 *
 * @author Rob Harrop
 * @since 2.0
 */
public interface AttributeAccessor {

	/**
	 * 设置属性的值
	 *
	 * @param name  属性名
	 * @param value 值
	 */
	void setAttribute(String name, @Nullable Object value);

	/**
	 * 获得指定属性名称的值,如果不存在返回null
	 *
	 * @param name 属性名
	 * @return 属性值
	 */
	@Nullable
	Object getAttribute(String name);

	/**
	 * 删除指定的name的属性,如果不存在则返回null
	 *
	 * @param name 属性名
	 * @return the last value of the attribute, if any
	 */
	@Nullable
	Object removeAttribute(String name);

	/**
	 * 判断指定的属性名称是否存在,注意属性名称必须是唯一的
	 *
	 * @param name 属性名
	 */
	boolean hasAttribute(String name);

	/**
	 * 得到所有属性的名称
	 */
	String[] attributeNames();

}
